<template>
  <slot :switch-language="switchLanguage"></slot>
</template>

<script setup lang="ts">
import { useI18n } from 'vue-i18n';
const i18n = useI18n();
const locale = toRef(i18n, 'locale');

const switchLanguage = function () {
  locale.value = locale.value === 'zh-CN' ? 'en-US' : 'zh-CN';
  localStorage.setItem('storedLanguage', locale.value);
};
</script>
